Program transformation systems need to support searching and manipulation of syntax structure (e.g., function definition, loop, variable declaration, etc.). Program formats (i.e., white spaces and comments) need to be preserved in an unchanged portion of transformed programs. To achieve these goals, a program transformation system needs to use program representations that record both syntax and formatting information of programs. Such representations are more complex than those used in program analysis tools or compilers, where only syntax information is needed. This added complexity and the need to preserve format information make it difficult to construct syntax-directed search and manipulations. There is a need for a technique for constructing search and manipulation operations that hides the complexity of the program representation and formatting preservation from transformation writers, allowing them to concentrate on syntax information.
One existing approach allows for query and manipulation of specified syntax structure. It allows matching on every syntax structures in languages, such as C, C++, Java, etc. If format information needs to be preserved, it must be explicitly described in the match and manipulation clause, making it more difficult to program transformations. Another existing approach allows search and replacement of specified code segments rather than individual syntax structures. It enables format preservation, but does not allow explicit syntax directed search and manipulations.